import http from '@/utils/request.js';
import obj from '@/utils/config.js';
import {
	hanleToken
} from '@/utils/utils.js';
export const login = (data) => {
	// return http.post('/repair-auth/oauth/token',data, false,true, false, false,hanleToken('get','roleId'));
	return http.request({
		url: '/repair-auth/oauth/token',
		method: 'post',
		data,
		roleId: hanleToken('get', 'roleId')
	});
};
// 退出
export const loginOut = () => {
	// return http.get('/repair-auth/oauth/logout');
	return http.request({
		url: '/repair-auth/oauth/logout',
		method: 'get',
	});
};

// 查找手机号是否有权限
export const checkPhone = (phone) => {
	// return http.get('/blade-user/checkPhone?phone=' + phone, {});
	return http.request({
		url: '/blade-user/checkPhone?phone=' + phone,
		method: 'get',
	});
};

// 微信授权
export const wxLogon = (data) => {
	// return http.post('/repair-auth/oauth/token/weixin',data);
	return http.request({
		url: '/repair-auth/oauth/token/weixin',
		method: 'post',
		data,
	});
};

// 获取验证码
export const getPhoneCode = (phone) => {
	// return http.post('/blade-resource/sms/endpoint/send-validate?phone=' + phone, {});
	return http.request({
		url: '/blade-resource/sms/endpoint/send-validate?phone=' + phone,
		method: 'post',
	});
};

// 修改密码
export const reSetPassword = (data) => {
	// return http.post('/blade-user/captcha-update-password',data);
	return http.request({
		url: '/blade-user/captcha-update-password',
		method: 'post',
		data,
	});
};
// // 刷新token
// export const refreshToken = () => {
// 	return http.post('/repair-auth/oauth/token', 

// 	)
// }

// /////////////// 页面修改后的登入//////////////////

// 获取验证码
export const getCodeNetworkApi = (data) => {
	// return http.post('/blade-resource/sms/endpoint/send-validate', data, false, false);
	return http.request({
		url: '/blade-resource/sms/endpoint/send-validate',
		method: 'post',
		data,
	});
};
// 修改手机号码获取验证码
export const getNewCode = (data) => {
	// return http.post('/blade-resource/sms/endpoint/send-validate/all', data, false, false);
	return http.request({
		url: '/blade-resource/sms/endpoint/send-validate/all',
		method: 'post',
		data,
	});
};

// 根据code获取openid
export const getOpenid = (data) => {
	// return http.get('/repair-auth/login/request/' + obj.appId, data);
	return http.request({
		url: '/repair-auth/login/request/' + obj.appId,
		method: 'get',
		data,
	});
};

// 获取微信手机号
export const getCallbackPhone = (data) => {
	// return http.post('/repair-auth/login/callback/' + obj.appId, data, false);
	return http.request({
		url: '/repair-auth/login/callback/' + obj.appId,
		method: 'post',
		data,
	});
};

// 查询该手机号码所拥有的维保公司列表
export const getTenantInfoByPhone = (data) => {
	// return http.get('/blade-user/getTenantInfoByPhone', data);
	return http.request({
		url: '/blade-user/getTenantInfoByPhone',
		method: 'get',
		data,
	});
};

// 更新或建立用户微信openid
export const setWxOpenid = (data) => {
	// return http.post(`/repair-auth/phone/login/callback/${data.appid}`, data);
	return http.request({
		url: `/repair-auth/phone/login/callback/${data.appid}`,
		method: 'post',
		data,
	});
};

// 授权微信号的登入
export const getUserToken = (data) => {
	// return http.post('/repair-auth/oauth/wx/token/' + obj.appId, data, false,true, false, false,hanleToken('get','roleId'));
	return http.request({
		url: '/repair-auth/oauth/wx/token/' + obj.appId,
		method: 'post',
		data,
		roleId: hanleToken('get', 'roleId')
	});
};

// 登录
export const userLogin = (data) => {
	// return http.post('/repair-auth/oauth/token', data, false);
	return http.request({
		url: '/repair-auth/oauth/token',
		method: 'post',
		data,
	});
};
// 角色登录
export const roleLogin = (data) => {
	// return http.post('/repair-auth/oauth/token', data, false,true, false, false,hanleToken('get','roleId'));
	return http.request({
		url: '/repair-auth/oauth/token',
		method: 'post',
		data,
		roleId: hanleToken('get', 'roleId')
	});
};
// 短信验证码的登入
export const getUserMessage = (data, captchaKey) => {
	// return http.post('/blade-resource/sms/endpoint/login-validate-message', data, false, true, false, captchaKey);
	return http.request({
		url: '/blade-resource/sms/endpoint/login-validate-message',
		method: 'post',
		data,
		type: false,
		toast: true,
		autoid: false,
		captchaKey
	});
};
// 获取状态区分账号是否关注公众号
export const getOfficialaccount = (data) => {
	// return http.get('/repair/user/weixin/official/account/info', data);
	return http.request({
		url: '/repair/user/weixin/official/account/info',
		method: 'get',
		data,
	});
};

// /blade-resource/sms/endpoint/send-validate
